package cn.aixmy.main.controller.admin;

import cn.aixmy.base.vo.Result;
import cn.aixmy.main.entity.Admin;
import cn.aixmy.main.service.AdminService;
import cn.aixmy.utils.IpUtils;
import cn.dev33.satoken.stp.StpUtil;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletRequest;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/web/admin/")
public class AdminController {

    @Resource
    AdminService adminService;

    @PostMapping("login")
    public Result login(@RequestBody Admin admin, HttpServletRequest request) {
        admin.setLastIp(IpUtils.getIpAddr(request));
        System.out.println(admin);
        return adminService.login(admin);
    }
}
